package com.sunway.lc.ftp.camel;

import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author Heyyroup
 * @Description
 * @date 2021/9/23
 */
//@Component
public class DownloadRoute extends RouteBuilder {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Value("${camel-ftp.url}")
    private String ftpServerUrl;

    @Value("${camel-ftp.dir}")
    private String localDir;
//
//    @Autowired
//    private DataProcessor dataProcessor;
    @Override
    public void configure() throws Exception {
        // 源
        String source = "file:D:/203eod/camel?recursive=true&delete=false&delay=5000&noop=true&idempotent=true";
        // 目标
        String target = "ftp://172.162.0.207:21?username=ftpuser_acc&password=ftp123123&recursive=true&reconnectDelay=1000&binary=true&passiveMode=true&delete=false&delay=5000&noop=true&idempotent=true&ftpClient.controlEncoding=UTF-8";
        from(source)
                // 本地路径
                .to(target)
                // 日志
                .log(LoggingLevel.INFO, logger, "Upload img ${file:name} complete.");
//        from(ftpServerUrl)
//                // 本地路径
//                .to(localDir)
//                // 日志
//                .log(LoggingLevel.INFO, logger, "Download img ${file:name} complete.");
    }
}
